//
//  FinishedSubHeader.m
//  RRQS
//
//  Created by kyjun on 16/3/29.
//
//

#import "FinishedSubHeader.h"

@interface FinishedSubHeader ()

@property(nonatomic,strong) UILabel* labelOrderNO;
@property(nonatomic,strong) UILabel* labelLiuShui;

//@property(nonatomic,strong) UILabel* labelMoney;
@property(nonatomic,strong) UILabel* labelStatus;
@property(nonatomic,strong) UIView* lineView;

@end

@implementation FinishedSubHeader

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if(self){
        self.contentView.backgroundColor = [UIColor colorWithRed:255/255.f green:255/255.f blue:255/255.f alpha:1.0];
        [self layoutUI];
//        [self layoutConstraints];
    }
    return self;
}

#pragma mark =====================================================  user interface layout
-(void)layoutUI{
    [self addSubview:self.labelOrderNO];
//    [self addSubview:self.labelMoney];
    [self addSubview:self.labelStatus];
    [self addSubview:self.labelLiuShui];
    [self addSubview:self.lineView];

    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self);
        make.left.right.equalTo(self);
        make.height.mas_equalTo(0.8);
    }];
    
    [self.labelStatus mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.right.equalTo(self).offset(-10);
    }];
    
    
    
    [self.labelOrderNO mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(5);
        make.left.equalTo(self).offset(10);
    }];
    
    
    [self.labelLiuShui mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.labelOrderNO.mas_bottom);
        make.left.equalTo(self).offset(10);
    }];

}

-(void)layoutConstraints{
//    self.labelOrderNO.translatesAutoresizingMaskIntoConstraints = NO;
//    self.labelMoney.translatesAutoresizingMaskIntoConstraints = NO;
    
    [self.labelOrderNO addConstraint:[NSLayoutConstraint constraintWithItem:self.labelOrderNO attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SCREEN_WIDTH*2/3]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelOrderNO attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelOrderNO attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:10.f]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelOrderNO attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.f]];
    
//    [self.labelMoney addConstraint:[NSLayoutConstraint constraintWithItem:self.labelMoney attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SCREEN_WIDTH/3]];
//    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelMoney attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.f]];
//    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelMoney attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:-10.f]];
//    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.labelMoney attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.f]];

    
}

#pragma mark =====================================================  property package
-(void)setEntity:(MOrder *)entity{
    if(entity){
        _entity = entity;
        self.labelOrderNO.text = [NSString stringWithFormat:@"总订单号: %@",entity.main_id];
        self.labelLiuShui.text = [NSString stringWithFormat:@"商家流水号: %@",entity.liushui];
        self.labelStatus.text = [NSString stringWithFormat:@"%@",@"已送达"];

        
    }
}

-(UILabel *)labelOrderNO{
    if(!_labelOrderNO){
        _labelOrderNO = [[UILabel alloc]init];
        _labelOrderNO.font = [UIFont systemFontOfSize:12.f];
        _labelOrderNO.textColor = [UIColor colorWithRed:135/255.f green:135/255.f blue:135/255.f alpha:1.0];
    }
    return _labelOrderNO;
}

-(UILabel *)labelStatus{
    if(!_labelStatus){
        _labelStatus = [[UILabel alloc]init];
        _labelStatus.textAlignment = NSTextAlignmentRight;
        _labelStatus.font = [UIFont systemFontOfSize:12.f];
        _labelStatus.textColor = [UIColor colorWithRed:90/255.f green:90/255.f blue:90/255.f alpha:1.0];
    }
    return _labelStatus;
}

-(UILabel *)labelLiuShui{
    if(!_labelLiuShui){
        _labelLiuShui = [[UILabel alloc]init];
        _labelLiuShui.font = [UIFont systemFontOfSize:12.f];
        _labelLiuShui.textColor = [UIColor colorWithRed:135/255.f green:135/255.f blue:135/255.f alpha:1.0];
    }
    
    return _labelLiuShui;
    
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView  = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithRed:231/255.0f green:231/255.0f blue:231/255.0f alpha:1.0f];
    }
    return _lineView;
}
@end
